No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage and retrieval system, without permission in writing from the publisher. However, you are permitted to make copies of this work, printed or otherwise, as long as said copies are for your personal use only.
Introduction
------------
Have you ever needed to format a piece of text to a certain column width? Some services need carriage returns at the end of each line. Give a text file to this hack and it will create a formatted text file of whatever column width you'd like.
To perform this hack, we use some cool text formatting features of MicroPhone. After all, why do the work ourselves if MicroPhone can do it for us?
Instructions - Put the module called 'TextFormat' in your Module Folder, which is in the same location as the MicroPhone application. If you do not have a Module Folder, create one. Open any MicroPhone settings document. Create the following script:
Do Script "'Main','TextFormat'"
That's it.
Theory
------
So, what's behind this hack? Let's take a quick look at the scripts in TextFormat. Here are the scripts in the TextFormat module:
Main
TextFormat
Main - this script simply calls the script TextFormat. It is used to provide a single entry point into the module. This way, you don't have to know the name of a particular script. Just call the main script in any of the modules that have been provided with Open Mike and they will do the right thing.
TextFormat - This script does the work of creating a new file with carriage return delimeters. Take a look at it to see what it's doing. Print the script and study it. Maybe you'll get some ideas you can use in your own scripting projects.
Where to go from here
---------------------
Because we are relying primarily on the text formatting features of MicroPhone, and we are at the mercy of how fast MicroPhone can send text to its terminal window, it would be nice if we could create an XCMD to do the same thing. Pass the XCMD an unformatted text file to format, and it would return you a nicely formatted text file. Maybe we'll investigate this in a future issue of Open Mike.
Important Note
--------------
Hacks are not guaranteed to work, although there is no reason why they shouldn't work. Every care has been taken to make sure that they work on the hacker's machine, but they may do other things on your machine. Of course, if you encounter problems, you may feel free to tweak the hack to run on your machine.